package com.example.WebSocketDemo.web;

import com.example.WebSocketDemo.service.MessageService;
import com.example.WebSocketDemo.service.RecentMessageService;
import com.example.WebSocketDemo.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;
    @Autowired
    private RecentMessageService recentMessageService;
    @GetMapping("/message")
    public Result getMessage(String from,String to,String chatType){
        recentMessageService.updateUnreadMessageCount(to,from);
        return Result.success(messageService.getMessageByFromUserAndToUserAndChatType(from,to,chatType));
    }
}
